<script setup lang="ts">
import { Assignment } from "../../index";
import { secToTime } from "../../utils.ts";
import { ref } from "vue";
import { downAssignmentURL } from "../../api/assignment.ts";

const props = defineProps<{ assignment: Assignment }>();

const second = secToTime(
  (new Date(props.assignment.deadline).getTime() - new Date().getTime()) / 1000
);

const url = ref<string>(`${downAssignmentURL}/${props.assignment.id}`);
</script>

<template>
  <el-card class="card p-1 mx-5 text-orange-500">
    <div>{{ assignment.title }}</div>
    <el-link :href="url">点击下载</el-link>
    <div class="float-right text-orange-500">截止日期: {{ second }}</div>
  </el-card>
</template>

<style scoped></style>
